package com.yww.mapper;

import com.yww.entity.Roles;
import com.yww.entity.UserRoles;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 杨雯雯
 * @since 2020-05-20
 */
public interface UserRolesMapper extends BaseMapper<UserRoles> {
    /**
     * 根据用户id查询该用户角色们
     * @param userId
     * @return
     */
    @Select("select * from roles where role_id in(select roles_id from user_roles where users_id=#{userId})")
    List<Roles> getRolesListByUserId(Integer userId);

    /**
     * 根据用户id批量删除角色
     * @param userId
     * @param ids
     * @return
     */
    boolean delRolesBatchByUserId(@Param("userId")Integer userId, @Param("ids")String[] ids);
}
